import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:dmz/base/controller/base_controller.dart';
import 'package:dmz/business/home/controller/home_main_controller.dart';
import 'package:dmz/business/home/model/moto_model.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../model/locus_data.dart';

class MapLocusController extends BaseController {
  @override
  void loadNet() {}

  @override
  void onHidden() {}

  LatLng? initLatLng;
  List<LatLng>? latLngs;
  late AMapController mapController;
  Map<String, Polyline>? initPolylinesMap; //轨迹
  Map<String, Marker> markerMap = {}; //标记点
  late MotoModel data;
  late LocusModle locusData;

  @override
  void onReady() {
    super.onReady();
    var controllered = Get.find<HomePageController>();
    data = controllered.motoList[controllered.pageIndex];
    latLngs = (Get.arguments as Map)['result'] as List<LatLng>;
    locusData = (Get.arguments as Map)['data'] as LocusModle;
    initLatLng = latLngs?.first;
    // Marker(position: latLng)
    markerMap['star'] = Marker(position: latLngs!.first); //标记点
    markerMap['end'] = Marker(position: latLngs!.last); //标记点
    initPolylinesMap = {
      'locus': Polyline(points: latLngs!, color: Color(0xFF23C565), width: 5)
    };
    update();
  }
}

class MapLocusBinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut(() => MapLocusController());
  }
}
